import axios from 'axios';

const API_BASE_URL = process.env.REACT_APP_API_BASE_URL;

export const userManagementApi = {
  // 获取用户列表
  getUsers: async (params) => {
    const response = await axios.get(`${API_BASE_URL}/admin/users`, { params });
    return response.data;
  },

  // 获取用户详情
  getUserById: async (userId) => {
    const response = await axios.get(`${API_BASE_URL}/admin/users/${userId}`);
    return response.data;
  },

  // 更新用户状态
  updateUserStatus: async (userId, status) => {
    const response = await axios.patch(`${API_BASE_URL}/admin/users/${userId}/status`, { status });
    return response.data;
  },

  // 更新用户角色
  updateUserRole: async (userId, role) => {
    const response = await axios.patch(`${API_BASE_URL}/admin/users/${userId}/role`, { role });
    return response.data;
  },

  // 重置用户密码
  resetUserPassword: async (userId) => {
    const response = await axios.post(`${API_BASE_URL}/admin/users/${userId}/reset-password`);
    return response.data;
  },

  // 导出用户数据
  exportUsers: async (params) => {
    const response = await axios.get(`${API_BASE_URL}/admin/users/export`, {
      params,
      responseType: 'blob'
    });
    return response.data;
  }
}; 